package com.ysh.mybatisdemo.service;


import com.ysh.mybatisdemo.mapper.UserInfoMapper;
import com.ysh.mybatisdemo.model.UserInfo;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    public List<UserInfo> getAllUser() {
        return userInfoMapper.selectAll();
    }

    public UserInfo getUserById(Integer id) {
        return userInfoMapper.selectById(id);
    }

    public UserInfo getUserByNameAndPassword  (String name,String password) {
        List<UserInfo> userInfos =  userInfoMapper.selectByUsernameAndPassword4(name,password);
        if (userInfos!=null && userInfos.size()>=1) {
            return userInfos.get(0);
        }
        return null;
    }
}
